var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function n() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })(),
  DragonChemistDialog = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.max = 50),
        (e.min = 1),
        (e.step = 1),
        (e.num = 1),
        (e.list_dragon_item.visible = !0),
        (e.list_dragon_item.selectEnable = !0),
        (e.list_dragon_item.vScrollBarSkin = ""),
        e.list_dragon_item.on(Laya.Event.CLICK, e, e.onDragonItemListDidClick),
        (e.list_dragon_item.renderHandler = new Handler(
          e,
          e.onDragonHandlerItem
        )),
        WebSocketService.addListener({
          caller: e,
          code: 6404,
          method: e.onLoadHundanFuJiangList,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 6406,
          method: e.onLoadHundanXiuLianFn,
        }),
        e.btn_drag_dele.on(Laya.Event.CLICK, e, e.onDidClickItemFn),
        e.btn_drag_plus.on(Laya.Event.CLICK, e, e.onDidClickItemFn),
        e.slider_dragDetail.on(Laya.Event.CHANGE, e, e.onSliderTrainChange),
        e.btn_dragon_start.on(Laya.Event.CLICK, e, e.onDragonStartAction),
        e
      );
    }
    return (
      __extends(e, t),
      (e.open = function () {
        null == this.dragonV &&
          ((this.dragonV = new e()), (this.dragonV.zOrder = 1e3)),
          this.dragonV.popup(!0),
          WebSocketService.send({ c: 6404 }),
          (this.dragonV.max = 100),
          (this.dragonV.slider_dragDetail.max = this.dragonV.max),
          (this.dragonV.slider_dragDetail.min = 0),
          (this.dragonV.slider_dragDetail.value = 0);
      }),
      (e.prototype.onLoadHundanFuJiangList = function (t) {
        if (0 == t.code) {
          this.listArr = [];
          for (var e = void 0, i = 0; i < t.data.length; i++) {
            var n = t.data[i];
            (e = {
              item_fujiang_name: {
                text:
                  this.dealRoleTouXiang(n.s) +
                  " " +
                  n.lvl +
                  "级 " +
                  this.dealRoleType(n.roleType) +
                  n.name,
              },
              id: n.id,
              s: n.s,
            }),
              0 == i && (this.lastSelectItem = e),
              this.listArr.push(e);
          }
          this.list_dragon_item.dataSource = this.listArr;
        }
      }),
      (e.prototype.dealRoleType = function (t) {
        return Utils.transform(t % 10, "roleType");
      }),
      (e.prototype.dealRoleTouXiang = function (t) {
        var e = "";
        return (
          "1" == t
            ? (e = "国士")
            : "2" == t
            ? (e = "将才")
            : "3" == t
            ? (e = "英才")
            : "4" == t && (e = "常人"),
          e
        );
      }),
      (e.prototype.onDragonItemListDidClick = function (t) {
        if ("" != t.target.name) {
          var e = this.list_dragon_item.selectedItem;
          (this.lastSelectItem = e), this.list_dragon_item.refresh();
        }
      }),
      (e.prototype.onDragonHandlerItem = function (t, e) {
        var i = t.getChildByName("item_fujiang_selected"),
          n = t.getChildByName("item_fujiang_name");
        this.lastSelectItem.id == this.listArr[e].id
          ? (i.text = "✔️")
          : (i.text = "");
        var a = this.listArr[e];
        n.color = Dictionary.colorType[a.s];
      }),
      (e.prototype.onDidClickItemFn = function (t) {
        "item0" == t.target.name
          ? ((this.num = this.num - this.step),
            this.num < this.min && (this.num = this.min),
            (this.slider_dragDetail.value = this.num))
          : "item1" == t.target.name &&
            ((this.num = this.num + this.step),
            this.num > this.max && (this.num = this.max),
            (this.slider_dragDetail.value = this.num)),
          (this.label_drag_fee.text =
            this.dealcostMoney(this.num) + "/" + this.num + "个");
      }),
      (e.prototype.onSliderTrainChange = function () {
        (this.num = this.slider_dragDetail.value),
          (this.label_drag_fee.text =
            this.dealcostMoney(this.num) + "/" + this.num + "个");
      }),
      (e.prototype.dealcostMoney = function (t) {
        return 70 * t + "金" + (60 * t + "分钟");
      }),
      (e.prototype.onDragonStartAction = function () {
        this.slider_dragDetail.value < 1
          ? ToastView.toastView("请选择次数")
          : this.lastSelectItem &&
            WebSocketService.send({
              c: 6406,
              d: {
                cid: this.lastSelectItem.id,
                c: this.slider_dragDetail.value,
              },
            });
      }),
      (e.prototype.onLoadHundanXiuLianFn = function (t) {
        0 == t.code && this.close(), ToastView.toastView(t.msg);
      }),
      e
    );
  })(ui.Estatemarket.DragonChemistDialogUI);
